<template>
  <laker-dialog
    v-model="visible"
    title="违章清单"
    width="900"
    height="900"
    :show-fullscreen="true"
    :show-close="true"
    destroy-on-close
    @closed="$emit('closed')"
  >
    <table class="laker-table">
      <tr>
        <th style="width: 30px">序号</th>
        <th style="width: 100px">检查日期</th>
        <th style="width: 100px">被考核部门</th>
        <th>违章事件内容</th>
        <th>处理依据</th>
        <th>处理结果</th>
        <th style="width: 50px">检查人</th>
        <th style="width: 50px">考核金额</th>
      </tr>
      <tr v-for="(item, index) in dataList" :key="index">
        <td>{{ index + 1 }}</td>
        <td>{{ item.bgbDate }}</td>
        <td>{{ item.cstName }}</td>
        <td>{{ item.bgbName }}</td>
        <td>{{ item.bgbBase }}</td>
        <td>{{ item.bgbDsc }}</td>
        <td>{{ item.userName }}</td>
        <td>{{ item.bgbAtm }}</td>
      </tr>
    </table>
  </laker-dialog>
  <hd-sign-table ref="siTableRef" v-if="dialog.siTable" @closed="dialog.siTable = false"></hd-sign-table>
</template>

<script>
import LakerDialog from '@/components/lakerDialog/index.vue'
import { dayjs } from 'element-plus'
import dprevent from '@/api/dprevent'
import HdSignTable from './HdSignTable.vue'

export default {
  name: 'BgbTable',
  components: { LakerDialog, HdSignTable },
  emits: ['success', 'closed'],
  data() {
    return {
      dialog: {
        siTable: false
      },
      mode: 'add',
      visible: false,
      titleMap: {
        add: '选择设备类型',
        edit: '编辑人员',
        show: '查看'
      },
      elmain: 'elmain',
      today: dayjs().format('YYYY-MM-DD'),
      risk01: 0,
      dataList: []
    }
  },
  mounted() {
    this.getApiData()
  },
  methods: {
    getApiData() {
      dprevent.getBgbList().then((res) => {
        if (res.code === 'success') {
          if (res.result) {
            this.dataList = res.result
          }
        }
      })
    },
    //显示
    open(mode = 'add') {
      this.mode = mode
      this.visible = true
      return this
    },
    close() {
      this.visible = false
      return this
    },
    //表单注入数据
    setData(data) {
      console.log(data)
    },
    openDetail(item) {
      this.dialog.siTable = true
      this.$nextTick(() => {
        this.$refs.siTableRef.open('show').setData(item)
      })
    }
  }
}
</script>

<style scoped lang="scss"></style>
